This sample code shows the use of the SearchButtonClicked Event (Window Object). Modify the following sample code to fit your needs.
Dim rpt As CRPEAuto.Report
Dim rptView As CRPEAuto.View
Dim test As Integer
Private Sub SearchButtonClicked_Click()
'Starts up report window for window event SearchButtonClicked
On Error GoTo ErrorHandler
Set rpt = crsApp.OpenReport("c:\crw\reports\xtreme\www.sales.rpt")
rpt.PrintWindowOptions.HasSearchButton = True
test = MsgBox("Event default: Enabled = " & _
rpt.EventInfo.PrintWindowButtonEventEnabled & Chr(13) & _
Chr(13) & "Disable event?", vbYesNo)
If test = vbYes Then
rpt.EventInfo.PrintWindowButtonEventEnabled = False
MsgBox "Check event does not occur when search button clicked"
Else
rpt.EventInfo.PrintWindowButtonEventEnabled = True
test = MsgBox("Check event occurs when search button clicked" & _
Chr(13) & Chr(13) & "Use default behaviour for test? ", vbYesNo)
If test = vbYes Then
def = True
Else
def = False
End If
End If
Set rptView = rpt.Preview
Set windowEvs = rptView.Parent
Exit Sub ' Exit to avoid handler.
ErrorHandler:
If crsApp.LastErrorCode <> 0 Then
MsgBox "Unexpected application error: " & _
crsApp.LastErrorCode & "->" & crsApp.LastErrorString
End If
If rpt.LastErrorCode <> 0 Then
MsgBox "Unexpected application error: " & _
rpt.LastErrorCode & "->" & rpt.LastErrorString
End If
If Err.Number <> 0 Then
MsgBox "Unexpected VB error: " & Err.Number & "->" & Err.Description
End If
Call ResetErr
rpt.ClearError
Resume Next
End Sub
Private Sub windowEvs_SearchButtonClicked(ByVal SearchString As String, _
useDefault As Boolean)
'executed when window search button clicked
If def Then
'test for default behaviour:
MsgBox "Window SearchButtonClicked event" & Chr(13) & _
Chr(13) & "Parameters:" & Chr(13) & "SearchString: " & _
SearchString & Chr(13) & "useDefault: " & useDefault & _
Chr(13) & Chr(13) & "Search should occur"
Else
'test for no default behaviour:
useDefault = False
MsgBox "Window SearchButtonClicked event" & Chr(13) & _
Chr(13) & "Parameters:" & Chr(13) & "SearchString: " & _
SearchString & Chr(13) & "useDefault: " & useDefault & _
Chr(13) & Chr(13) & "Search should NOT occur"
End If
End Sub
Seagate Software IMG Holdings, Inc. http://www.seagatesoftware.com Support services: http://support.seagatesoftware.com |